<%#
 Copyright 2013-2020 the original author or authors from the JHipster project.

 This file is part of the JHipster project, see https://www.jhipster.tech/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
<div>
    <div class="row justify-content-center">
        <div class="col-md-8">
            <h1 jhiTranslate="reset.request.title">Reset your password</h1>

            <<%= jhiPrefixDashed %>-alert-error></<%= jhiPrefixDashed %>-alert-error>

            <div class="alert alert-warning" *ngIf="!success">
                <span jhiTranslate="reset.request.messages.info">Enter the email address you used to register.</span>
            </div>

            <div class="alert alert-success" *ngIf="success">
                <span jhiTranslate="reset.request.messages.success">Check your emails for details on how to reset your password.</span>
            </div>

            <form *ngIf="!success" name="form" role="form" (ngSubmit)="requestReset()" [formGroup]="resetRequestForm">
                <div class="form-group">
                    <label class="form-control-label" for="email" jhiTranslate="global.form.email.label">Email</label>
                    <input type="email" class="form-control" id="email" name="email" placeholder="{{ 'global.form.email.placeholder' | translate }}"
                           formControlName="email" data-cy="emailResetPassword" #email>

                    <div *ngIf="resetRequestForm.get('email')!.invalid && (resetRequestForm.get('email')!.dirty || resetRequestForm.get('email')!.touched)">
                        <small class="form-text text-danger"
                               *ngIf="resetRequestForm.get('email')?.errors?.required"
                               jhiTranslate="global.messages.validate.email.required">
                            Your email is required.
                        </small>

                        <small class="form-text text-danger"
                               *ngIf="resetRequestForm.get('email')?.errors?.email"
                               jhiTranslate="global.messages.validate.email.invalid">
                            Your email is invalid.
                        </small>

                        <small class="form-text text-danger"
                               *ngIf="resetRequestForm.get('email')?.errors?.minlength"
                               jhiTranslate="global.messages.validate.email.minlength">
                            Your email is required to be at least 5 characters.
                        </small>

                        <small class="form-text text-danger"
                               *ngIf="resetRequestForm.get('email')?.errors?.maxlength"
                               jhiTranslate="global.messages.validate.email.maxlength">
                            Your email cannot be longer than 100 characters.
                        </small>
                    </div>
                </div>

                <button type="submit" [disabled]="resetRequestForm.invalid" class="btn btn-primary" jhiTranslate="reset.request.form.button" data-cy="submit">Reset</button>
            </form>
        </div>
    </div>
</div>
